package com.lovo.test.MapText;

import java.util.*;

public class MapArray {
    public static void main(String[] args) {
        List list = Arrays.asList("a", "b", "a", "b", "c", "a", "b", "c", "b");
        int countA = 0;
        int countB = 0;
        int countC = 0;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).equals("a")) {
                countA++;
            } else if (list.get(i).equals("b")) {
                countB++;
            } else {
                countC++;
            }
        }

        HashSet set = new HashSet();
        set.addAll(list);
        List list1 = new ArrayList();
        list1.addAll(set);

        HashMap hashMap = new HashMap();
       hashMap.put("a",countA);
        hashMap.put("b",countB);
        hashMap.put("c",countC);
        Set set1 = hashMap.keySet();
        for (Object obj: set1
             ) {
            System.out.println(obj+":"+hashMap.get(obj));
        }

    }
}
